Passed
Push — master ( 4fc8e9...0ebefa )
by Kevin Van
01:32 queued 12s
created

IndexPage.renderLayoutMain   B

Complexity

Conditions 5

Size

Total Lines 27
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 27
rs 8.8133
c 0
b 0
f 0
cc 5
1
import { graphql } from "gatsby"
2
import React, { Component, Fragment } from "react"
3
4
import { CardImage } from "../components/Card"
5
import Card from "../components/Card"
6
import KcvvTvOverview from "../components/KcvvTvOverview"
7
import MatchesOverview from "../components/MatchesOverview"
8
import MatchesSlider from "../components/MatchesSlider"
9
import MatchesTabs from "../components/MatchesTabs"
10
import UpcomingEvent from "../components/UpcomingEvent.tsx"
11
import { NewsItemFeatured, NewsItemCardRatio } from "../components/news-item"
12
import SEO from "../components/seo"
13
import MyMakro from "../images/tag-mymakro.png"
14
import Trooper from "../images/tag-trooper.png"
15
import Layout from "../layouts/index"
16
17
class IndexPage extends Component {
18
  renderMatchSlider = () => (
19
    <section className={`grid-container full`}>
20
      <MatchesSlider />
21
    </section>
22
  )
23
  renderSocialMediaArticle = () => (
24
    <article className={`medium-6 large-12 cell social`}>
25
      <div className={`social-sidebar__wrapper`}>
26
        <a
27
          href="https://facebook.com/KCVVElewijt"
28
          className="btn-social-counter btn-social-counter--fb"
29
          target="_blank"
30
          rel="noopener noreferrer"
31
        >
32
          <div className="btn-social-counter__icon">
33
            <i className="fa fa-facebook"></i>
34
          </div>
35
          <h5 className="btn-social-counter__title">Volg onze Facebook pagina</h5>
36
        </a>
37
        <a
38
          href="https://twitter.com/kcvve"
39
          className="btn-social-counter btn-social-counter--twitter"
40
          target="_blank"
41
          rel="noopener noreferrer"
42
        >
43
          <div className="btn-social-counter__icon">
44
            <i className="fa fa-twitter"></i>
45
          </div>
46
          <h5 className="btn-social-counter__title">Volg ons op Twitter</h5>
47
        </a>
48
        <a
49
          href="http://www.instagram.com/kcvve"
50
          className="btn-social-counter btn-social-counter--instagram"
51
          target="_blank"
52
          rel="noopener noreferrer"
53
        >
54
          <div className="btn-social-counter__icon">
55
            <i className="fa fa-instagram"></i>
56
          </div>
57
          <h5 className="btn-social-counter__title">Volg ons op Instagram</h5>
58
        </a>
59
      </div>
60
    </article>
61
  )
62
63
  renderMakroArticle = () => (
64
    <Card className={`medium-6 large-12 cell card`} title="MyMakro">
65
      <p>
66
        Link nu jouw Makro voordeelkaart aan onze vereniging. Bij elke aankoop bij Makro en partners steun je KCVV
67
        Elewijt!
68
      </p>
69
      <p>
70
        <img src={MyMakro} alt="QR Code MyMakro" style={{ width: `100%` }} />
71
      </p>
72
      <p>
73
        Scan bovenstaande QR-code met je camera op GSM, of surf naar{` `}
74
        <a
75
          href="https://my.makro.be/nl/link-vereniging/02277464"
76
          target="_blank"
77
          rel="noopener noreferrer"
78
          title="MyMakro link voor KCVV Elewijt"
79
          className={`rich-link`}
80
        >
81
          https://my.makro.be/nl/link-vereniging/02277464
82
        </a>
83
        .
84
      </p>
85
      <p>Onze vereniging dankt jullie van harte!</p>
86
    </Card>
87
  )
88
  renderTrooperArticle = () => (
89
    <Card className={`medium-6 large-12 cell card`} title="Trooper">
90
      <p>
91
        Trooper werkt samen met een groot aantal webshops die zich in de kijker willen zetten. In ruil voor een extra
92
        klik via Trooper krijgen wij een percentje op jouw volgende bestelling.
93
      </p>
94
      <p>
95
        <img src={Trooper} alt="QR Code Trooper" style={{ width: `100%` }} />
96
      </p>
97
      <p>
98
        Scan bovenstaande QR-code met je camera op GSM, of surf naar{` `}
99
        <a
100
          href="https://trooper.be/kcvvelewijt"
101
          target="_blank"
102
          rel="noopener noreferrer"
103
          title="Trooper link voor KCVV Elewijt"
104
          className={`rich-link`}
105
        >
106
          https://trooper.be/kcvvelewijt
107
        </a>
108
        .
109
      </p>
110
      <p>
111
        <a href="/news/2020-04-12-steun-kcvv-elewijt-trooper-mymakro" className={`rich-link`}>
112
          Lees er hier meer over!
113
        </a>
114
      </p>
115
    </Card>
116
  )
117
  renderYouthCalendarArticle = () => (
118
    <Card className={`medium-6 large-12 cell`} title="Jeugdploegen" hasTable={true}>
119
      <MatchesOverview exclude={[`1`, `2`]} action="next" />
120
    </Card>
121
  )
122
123
  renderBTeamCalendarArticle = () => (
124
    <Card className={`medium-6 large-12 cell`} title="The B-Team" hasTable={true}>
125
      <MatchesTabs teamId="2" />
126
    </Card>
127
  )
128
  renderATeamCalendarArticle = () => (
129
    <Card className={`medium-6 large-12 cell`} title="The A-Team" hasTable={true}>
130
      <MatchesTabs teamId="1" />
131
    </Card>
132
  )
133
134
  renderTablebooker = () => (
135
    <Fragment>
136
      <Card className={`medium-6 large-12 cell card`} title="Mosselfestijn" titleIcon="fa-cutlery">
137
        <p>
138
          Op vrijdag 10, zaterdag 11 en zondag 12 september 2021 vindt ons jaarlijkse Mosselfestijn weer plaats. Om de
139
          spreiding te kunnen garanderen en wachttijden aan de ingang zoveel mogelijk te beperken werken we dit jaar
140
          opnieuw met een reservatiesysteem. Hieronder kan je zelf jouw gewenste tijdstip en gezelschap selecteren en
141
          een tafel boeken (voor 08/09/2021).
142
        </p>
143
        <p>
144
          Telefonisch reserveren kan dagelijks tussen 18u en 21u op het nummer
145
          {` `}
146
          <a href="tel:+32475981611">0475/98.16.11</a>
147
        </p>
148
        <p>
149
          Ter plaatse een tafel vragen kan, naargelang de beschikbaarheid op dat moment, maar hou er rekening mee dat we
150
          onze capaciteit hebben moeten verlagen om aan de regelgeving te kunnen voldoen. Wie zeker wil zijn van zijn
151
          plek kan beter reserveren.
152
        </p>
153
      </Card>
154
      <article className={`medium-6 large-12 cell tablebooker`}>
155
        <tbkr-bm-widget
156
          restaurant-id="34742560"
157
          source="website"
158
          use-modal="0"
159
          lang="nl"
160
          theme="light"
161
        ></tbkr-bm-widget>
162
        <script src="https://reservations.tablebooker.com/tbkr-widget-import.min.js"></script>
163
      </article>
164
    </Fragment>
165
  )
166
167
  renderWebsiteFeedbackArticle = () => (
168
    <Card className={`medium-6 large-12 cell card`} title="Website feedback" titleIcon="fa-commenting-o">
169
      <p>
170
        Na lang zwoegen is onze nieuwe website eíndelijk online geraakt! We zijn heel benieuwd naar jullie mening of
171
        feedback. Als jullie vinden dat er iets ontbreekt, of als je bepaalde fouten tegenkomt, zouden we het ten
172
        zeerste appreciëren als je ons even iets laat weten op{` `}
173
        <a href="mailto:[email protected]" className={`rich-link`}>
174
          [email protected]
175
        </a>
176
        !
177
      </p>
178
    </Card>
179
  )
180
  renderExtraContentFooter = (preseason) => (
181
    <section className="grid-container site-content">
182
      <div className="grid-x grid-margin-x">
183
        <section className={`cell large-12 featured-article`}>
184
          <CardImage title="Update voorbereiding 2020-2021" picture={preseason} link="/games" metadata={false} />
185
        </section>
186
      </div>
187
    </section>
188
  )
189
190
  // convertGraphqlToPlayerObject = (player) => {
191
  //   return {
192
  //     nameFirst: player.field_firstname,
193
  //     nameLast: player.field_lastname,
194
  //     shirtNr: player.field_shirtnumber,
195
  //     position: player.field_position,
196
  //     imageSrc:
197
  //       player.relationships.field_image.localFile.childImageSharp.fixed.src,
198
  //     link: player.path.alias,
199
  //   }
200
  // }
201
202
  // renderPlayerOfTheWeek = (featuredPlayer) =>
203
  //   featuredPlayer.edges.map(
204
  //     ({ node: potw }) =>
205
  //       potw.relationships.field_player && (
206
  //         <article
207
  //           className={"medium-6 large-12 cell card"}
208
  //           key={potw.relationships.field_player.field_firstname}
209
  //         >
210
  //           <header className={"card__header"}>
211
  //             <h4>Speler van de week</h4>
212
  //           </header>
213
  //           <PlayerFeatured
214
  //             player={this.convertGraphqlToPlayerObject(
215
  //               potw.relationships.field_player
216
  //             )}
217
  //           />
218
  //         </article>
219
  //       )
220
  //   )
221
222
  renderPosts = (posts) => {
223
    return posts.map(({ node }, i) => {
224
      return (
225
        <Fragment key={i}>
226
          {node.field_featured && <NewsItemFeatured node={node} />}
227
          {!node.field_featured && <NewsItemCardRatio node={node} teaser={true} />}
228
        </Fragment>
229
      )
230
    })
231
  }
232
233
  renderLayoutSidebar = () => {
234
    // const { featuredPlayer } = this.props.data
235
    return (
236
      <Fragment>
237
        {/* TABLEBOOKER WIDGET */}
238
        {/* this.renderTablebooker() */}
239
        {/* A TEAM OVERVIEW - SUMMARY OF MATCHES AND RANKING*/}
240
        {this.renderATeamCalendarArticle()}
241
        {/* B TEAM OVERVIEW - SUMMARY OF MATCHES AND RANKING */}
242
        {this.renderBTeamCalendarArticle()}
243
        {/* YOUTH TEAMS OVERVIEW - SUMMARY OF UPCOMING MATCHES */}
244
        {this.renderYouthCalendarArticle()}
245
        {/* PLAYER OF THE WEEK ARTICLE IF ANY */}
246
        {/* {featuredPlayer && this.renderPlayerOfTheWeek(featuredPlayer)} */}
247
        {/* INFO ARTICLE WITH SOCIAL MEDIA LINKS */}
248
        {this.renderSocialMediaArticle()}
249
        {/* INFO ARTICLE WITH REQUEST FOR WEBSITE FEEDBACK */}
250
        {this.renderWebsiteFeedbackArticle()}
251
        {/* INFO ARTICLE WITH "TROOPER" CONTENT */}
252
        {this.renderTrooperArticle()}
253
        {/* INFO ARTICLE WITH "MYMAKRO" CONTENT */}
254
        {this.renderMakroArticle()}
255
      </Fragment>
256
    )
257
  }
258
259
  calcFeaturedPosts = (posts) => {
260
    let featured = 0
261
    posts.forEach((post) => {
262
      if (post.field_featured) {
263
        featured++
264
      }
265
    })
266
267
    return featured
268
  }
269
270
  renderLayoutMain = () => {
271
    const { featuredPosts } = this.props.data
272
    const quotient1 = this.calcFeaturedPosts(featuredPosts.edges.slice(0, 1)) % 2
273
    const quotient2 =
274
      (quotient1 !== 0
275
        ? this.calcFeaturedPosts(featuredPosts.edges.slice(0))
276
        : this.calcFeaturedPosts(featuredPosts.edges.slice(1))) % 2
277
278
    return (
279
      <Fragment>
280
        <UpcomingEvent />
281
        {featuredPosts &&
282
          (quotient1 !== 0
283
            ? this.renderPosts(featuredPosts.edges.slice(0, 0))
284
            : this.renderPosts(featuredPosts.edges.slice(0, 1)))}
285
286
        <KcvvTvOverview />
287
288
        {featuredPosts &&
289
          featuredPosts.edges.length > 6 &&
290
          this.renderPosts(
291
            featuredPosts.edges.slice(
292
              quotient1 !== 0 ? 0 : 1,
293
              quotient2 !== 0 ? featuredPosts.edges.length : featuredPosts.edges.length - 1
294
            )
295
          )}
296
      </Fragment>
297
    )
298
  }
299
300
  render() {
301
    return (
302
      <Layout>
303
        <SEO
304
          lang="nl-BE"
305
          title="Er is maar één plezante compagnie"
306
          description="Startpagina van stamnummer 00055: KCVV Elewijt."
307
        />
308
        {/* {this.renderExtraContentFooter(this.props.data.preseason)} */}
309
310
        <section className="grid-container site-content">
311
          {/* LIMITED-WIDTH CONTAINER WITH EXTRA (STICKY) CONTENT, IF ANY */}
312
313
          <div className="grid-x grid-margin-x">
314
            <section className="cell large-8 news_overview__wrapper">
315
              {/* MAIN CONTENT AREA */}
316
              {this.renderLayoutMain()}
317
            </section>
318
            <aside className="cell large-4">
319
              <section className="grid-x featured__matches grid-margin-x">
320
                {/* SIDEBAR CONTENT */}
321
                {this.renderLayoutSidebar()}
322
              </section>
323
            </aside>
324
          </div>
325
        </section>
326
327
        {/* FULL-WIDTH SLICK SLIDER WITH UPCOMING MATCHES */}
328
        {this.renderMatchSlider()}
329
      </Layout>
330
    )
331
  }
332
}
333
334
export const pageQuery = graphql`
335
  query {
336
    featuredPosts: allNodeArticle(
337
      filter: { status: { eq: true }, promote: { eq: true } }
338
      sort: { fields: created, order: DESC }
339
      limit: 12
340
    ) {
341
      edges {
342
        node {
343
          id
344
          path {
345
            alias
346
          }
347
          created(formatString: "D/M/YYYY")
348
          changed(formatString: "D/M/YYYY")
349
          timestamp: changed(formatString: "x")
350
          title
351
          promote
352
          status
353
          field_featured
354
          body {
355
            value
356
            format
357
            processed
358
            summary
359
          }
360
          relationships {
361
            field_media_article_image {
362
              ...ArticleImage
363
            }
364
            field_tags {
365
              name
366
              path {
367
                alias
368
              }
369
            }
370
          }
371
          internal {
372
            type
373
          }
374
        }
375
      }
376
    }
377
    preseason: file(name: { eq: "preseason2020-2021" }) {
378
      ...KCVVFluid960
379
    }
380
    featuredPlayer: allNodePotw(sort: { fields: created, order: DESC }, filter: { status: { eq: true } }, limit: 1) {
381
      edges {
382
        node {
383
          relationships {
384
            field_player {
385
              field_firstname
386
              field_lastname
387
              field_shirtnumber
388
              field_position
389
              relationships {
390
                field_image {
391
                  localFile {
392
                    ...KCVVFixedPlayerTeaser
393
                  }
394
                }
395
              }
396
              path {
397
                alias
398
              }
399
            }
400
          }
401
        }
402
      }
403
    }
404
  }
405
`
406
407
export default IndexPage
408